package com.tristia.entity.util;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.tristia.entity.Person;
import com.tristia.service.PersonService;

public class PersonDataLoader {
	private List<Person> persons = new ArrayList<Person>();
	private PersonService personService;
	
	public void loadData() {
		for (Person person : persons) {
			personService.save(person);
		}
		persons.clear();
		persons = null;
	}

	public void setPersons(List<Person> persons) {
		this.persons = persons;
	}
	@Autowired
	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}
	
	public void init() {
		loadData();
	}

}
